package org.liveboardgames.agricola.vo.player
{
	import com.adobe.cairngorm.vo.IValueObject;
	
	import mx.collections.ListCollectionView;
	
	import org.liveboardgames.agricola.model.enums.AbstractEnum;
	import org.liveboardgames.agricola.vo.common.Target;
	import org.liveboardgames.agricola.vo.farm.Farm; 

	/**
	 * The player class is an abstraction of a real player
	 * from the original Agricola game.
	 */
	[RemoteClass(alias="org.liveboardgames.agricola.domain.player.Player")]
	[Bindable]
	public class Player implements Target, IValueObject
	{
		public var id:int;
		
		/**
		 * The name (alias) of the player. In the long run, this
		 * should disappear and be replaced by a reference to the
		 * account of the player (that will hold all necessary pieces
		 * of information to identify the player throughout the whole
		 * server).
		 */
		public var name:String;

		/**
		 * The color of the player's board elements, like the family
		 * members.
		 */
		public var color:String;

		/**
		 * Whether the player has already performed the harvest.
		 * TODO: this may not really be part of the player, but rather the
		 * state of the game.
		 */
		public var hasHarvested:Boolean;

		/**
		 * The farm associated to this player.
		 */
		public var farm:Farm;
		
		public var peeps:ListCollectionView;
		
		public var score:Score;

		public function toString():String
		{
			var result:String = "";
			if (name != null && name.length > 0)
			{
				result = name;
			}
			else
			{
				result = AbstractEnum.toTitleCase(color);
			}
			return result;
		}

	}
}